/**
 *  * @author Jeson
 *  * @date:2015-12-18 下午02:02:10
 *  * @version :3.0
 *  *
 *  
 */
package com.ctvit.wsservice.basedata.service;

import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.xml.datatype.XMLGregorianCalendar;

import com.ctvit.framework.dao.GenericDao;
import com.ctvit.framework.service.BaseService;
import com.ctvit.framework.util.HttpUtils;
import com.ctvit.framework.web.context.ContextHolder;
import com.ctvit.wsservice.basedata.domain.ZcdmTAdSch;
import com.ctvit.wsservice.basedata.domain.ZcdmTDev;
import com.ctvit.wsservice.basedata.domain.ZcdmTFinalitemWithBLOBs;
import com.ctvit.wsservice.basedata.domain.ZcdmTFinallist;
import com.ctvit.wsservice.basedata.domain.ZcdmTFinalseg;
import com.ctvit.wsservice.basedata.domain.ZcdmTInnerad;
import com.ctvit.wsservice.basedata.domain.ZcdmTProglist;
import com.ctvit.wsservice.basedata.domain.ZcdmTProrec;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.json.JSONObject;

@SuppressWarnings("serial")
public class FinalBCListService extends BaseService {

    private static final Logger LOGGER = Logger.getLogger(FinalBCListService.class);


    private Properties properties = new Properties();

    /**
     * @param zcdmTProrec
     * @return -1 参数异常 0插入成功 1更新失败
     * @ps: 节目播出单插入数据库(主表和子表)
     */

    private int checkFinalList(String zProRecCd) {
        String sql = "select * from zcdm_t_finallist where Z_PRO_REC_CD =  '" + zProRecCd + "'";
        List<Map<String, ?>> list = genericDao.executeSql(sql);
        if (list == null || list.isEmpty()) {
            return 0;
        } else {
            return 1;
        }
    }

    public int saveFinalList(ZcdmTFinallist zcdmTFinallist, List<ZcdmTFinalitemWithBLOBs> list, List<ZcdmTInnerad> zcdmTInneradList, List<ZcdmTAdSch> zcdmTAdSchList, List<ZcdmTFinalseg> finalSegList, List<ZcdmTDev> zcdmTDevList) {
        int ll_return = 0;

        if (zcdmTFinallist == null && list == null && list.isEmpty()) {
            ll_return = -1;
            return ll_return; // 参数异常!
        }

        if (checkFinalList(zcdmTFinallist.getzProRecCd()) > 0) {   //如何存在播后单
            String sql = "delete from zcdm_t_finallist where Z_PRO_REC_CD =  '" + zcdmTFinallist.getzProRecCd() + "'";
            genericDao.deleteBySqlStr(sql);

            String sql_item = "delete from zcdm_t_finalitem where Z_PRO_REC_CD =  '" + zcdmTFinallist.getzProRecCd() + "'";
            genericDao.deleteBySqlStr(sql_item);

            ZcdmTFinalitemWithBLOBs zcdmTFinalitem = new ZcdmTFinalitemWithBLOBs();
            for (int i = 0; i < list.size(); i++) {

                zcdmTFinalitem = new ZcdmTFinalitemWithBLOBs();
                zcdmTFinalitem = list.get(i);

                String sql_innerad = "delete from zcdm_t_innerad where Z_PRO_ITEM_CD =  '" + zcdmTFinalitem.getzProItemCd() + "'";
                genericDao.deleteBySqlStr(sql_innerad);

                String sql_finalSeg = "delete from zcdm_t_finalseg where Z_FATHER_ITEM_CD =  '" + zcdmTFinalitem.getzProItemCd() + "'";
                genericDao.deleteBySqlStr(sql_finalSeg);

                //有问题暂时注释
                try {
                    String sql_adsch = "delete from zcdm_t_ad_sch where Z_PRO_ITEM_CD =  '" + zcdmTFinalitem.getzProItemCd() + "'";
                    genericDao.deleteBySqlStr(sql_adsch);
                } catch (Exception e) {
                    log.error("广告zcdm_t_ad_sch删除信息失败:",e);
                }

//				String sql_dev = "delete from zcdm_t_dev where Z_PRO_ITEM_CD =  '" + zcdmTFinalitem.getzProItemCd()+"'";
//				genericDao.deleteBySqlStr(sql_dev);

            }

        }


        String sql_insert = "insert into zcdm_t_finallist(Z_PRO_REC_CD,Z_PLAY_DATE,Z_CHANL_CD,Z_CRUSR) values('" + zcdmTFinallist.getzProRecCd() + "','" + zcdmTFinallist.getzPlayDate() + "','" + zcdmTFinallist.getzChanlCd() + "','EM11')";
        int ll_finallist = genericDao.updateBySqlStr(sql_insert);

        int ll_finalitem = 0;
        if (ll_finallist > 0) {

            List<Map<String, Object>> yyglFinalItems = new ArrayList<>();
            String sql_item = "";
            ZcdmTFinalitemWithBLOBs zcdmTFinalitem = new ZcdmTFinalitemWithBLOBs();

            for (int i = 0; i < list.size(); i++) {
                zcdmTFinalitem = new ZcdmTFinalitemWithBLOBs();
                zcdmTFinalitem = list.get(i);
                yyglFinalItems.add(convertPoToMap(zcdmTFinalitem));
                sql_item = "";
                sql_item = "insert into zcdm_t_finalitem (Z_PRO_ITEM_CD, " +
                        " Z_PRO_REC_CD, Z_SUBJ_PLAN_ID, Z_PLAN_MATCH,  " +
                        "  Z_ORDER, Z_EVENT, Z_PLAY_TIME,  " +
                        "  Z_SUBJ_TIME, " +
//					     "Z_SUBJ_LENGTH, Z_PRO_RTMLEN,  "+
                        " Z_PRO_LENGTH, Z_SUBJ_CD, Z_PROCODE,  " +
                        "  Z_AUD_VER,Z_AUD_NAME, Z_CAP_VER,Z_CAP_NAME, Z_HD_FLAG,  " +
                        "  Z_AFD, Z_CARRIER_TYPE, Z_PLAY_FORM,  " +
                        "  Z_IN_FORM, Z_IS_NEWS_FLAG, Z_IS_AD,  " +
                        "  Z_CHANL_CASING, Z_PLAYROOM, Z_PRO_ITEM_STA,  " +
                        "  Z_PROG_SEGSUM, Z_LIMIT_AD, Z_INSERT_WAY,  " +
                        "  Z_BREAKPOINT_ID, Z_BEF_LENGTH, Z_MARKIN,  " +
                        "  Z_AD_SEGMENT_ID, Z_MEDIA_SEG, Z_MEDIA_TR_IN,  " +
                        "  Z_TRANS_TAPE, Z_SUPER_VISION, Z_PARENT_ITEM_CD,  " +
//					    "  Z_TOPIC_CD, Z_SPE_CD, Z_MAKE_SUBJ_CD,  "+
//					    "  Z_REP_FLAG, Z_DEPT_CD, Z_CENTER_CD,  "+
//					    "  Z_PGTYP, Z_PG_ROOT_TYP, Z_EPSD_SUM,  "+
//					    "  Z_EPSD_SEQNUM, Z_PRO_ATRBT, Z_ATTRIBUTE,  "+
                        "  Z_BREAK_FLG, Z_AD_TIME, Z_CHANL_CD,  " +
                        "   Z_CHANL_NAME," +
//					    " Z_CHANL_TYPE, Z_CHANL_REGION,  "+
                        "   Z_PLAY_DATE, " +
//					     "Z_TELEPLAY_BUCD, Z_TELEPLAY_BUNM,  "+
//					    "  Z_PLAY_CNT, Z_EXTEND1, Z_EXTEND2,  "+
//					    "  Z_EXTEND3, Z_EXTEND4, Z_EXTEND5,  "+
                        "  Z_CRUSR, Z_CRDAT,   " +
                        "  Z_UPUSR, Z_UPDAT,   " +
                        "  Z_SUBJ_NAME, Z_PGNAM, Z_AUDIO_TYPE,  " +
                        "  Z_PLAYROOM_NM, Z_MEDIA_ID, Z_MEDIA_NAME,  " +
                        "  Z_PRO_INSERT" +
//					     " Z_MAKE_SUBJ_NM, Z_PROD_TYPE "+
                        "  ) " +
                        " values ('" + zcdmTFinalitem.getzProItemCd() + "'," +
                        "'" + zcdmTFinalitem.getzProRecCd() + "', '" + zcdmTFinalitem.getzSubjPlanId() + "', '" + zcdmTFinalitem.getzPlanMatch() + "', " +
                        " " + zcdmTFinalitem.getzOrder() + ", '" + zcdmTFinalitem.getzEvent() + "', '" + zcdmTFinalitem.getzPlayTime() + "', " +
                        " '" + zcdmTFinalitem.getzSubjTime() + "', " +
//					    	      		+ "'"+zcdmTFinalitem.getzSubjLength()+"', '"+zcdmTFinalitem.getzProRtmlen()+"', "+
                        " '" + covertStr(zcdmTFinalitem.getzProLength()) + "', '" + zcdmTFinalitem.getzSubjCd() + "', '" + zcdmTFinalitem.getzProcode() + "', " +
                        "'" + zcdmTFinalitem.getzAudVer() + "', '" + zcdmTFinalitem.getzAudName() + "', '" + zcdmTFinalitem.getzCapVer() + "','" + zcdmTFinalitem.getzCapName() + "',  '" + zcdmTFinalitem.getzHdFlag() + "', " +
                        "'" + zcdmTFinalitem.getzAfd() + "', '" + zcdmTFinalitem.getzCarrierType() + "', '" + zcdmTFinalitem.getzPlayForm() + "', " +
                        "'" + zcdmTFinalitem.getzInForm() + "', '" + zcdmTFinalitem.getzIsNewsFlag() + "', '" + zcdmTFinalitem.getzIsAd() + "', " +
                        "'" + zcdmTFinalitem.getzChanlCasing() + "', '" + zcdmTFinalitem.getzPlayroom() + "', '" + zcdmTFinalitem.getzProItemSta() + "', " +
                        "  " + zcdmTFinalitem.getzProgSegsum() + ", " + zcdmTFinalitem.getzLimitAd() + ", '" + zcdmTFinalitem.getzInsertWay() + "', " +
                        "   '" + zcdmTFinalitem.getzBreakpointId() + "', '" + zcdmTFinalitem.getzBefLength() + "', '" + covertStr(zcdmTFinalitem.getzMarkin()) + "', " +
                        "'" + zcdmTFinalitem.getzAdSegmentId() + "', " + zcdmTFinalitem.getzMediaSeg() + ", '" + covertStr(zcdmTFinalitem.getzMediaTrIn()) + "', " +
                        "'" + zcdmTFinalitem.getzTransTape() + "', '" + zcdmTFinalitem.getzSuperVision() + "', '" + zcdmTFinalitem.getzParentItemCd() + "', " +
//					    	      "'"+zcdmTFinalitem.getzTopicCd()+"', '"+zcdmTFinalitem.getzSpeCd()+"', '"+zcdmTFinalitem.getzMakeSubjCd()+"', "+
//					    	      "'"+zcdmTFinalitem.getzRepFlag()+"', '"+zcdmTFinalitem.getzDeptCd()+"', '"+zcdmTFinalitem.getzCenterCd()+"', "+
//					    	      "'"+zcdmTFinalitem.getzPgtyp()+"', '"+zcdmTFinalitem.getzPgRootTyp()+"', '"+zcdmTFinalitem.getzEpsdSum()+"', "+
//					    	      "'"+zcdmTFinalitem.getzEpsdSeqnum()+"', '"+zcdmTFinalitem.getzProAtrbt()+"', '"+zcdmTFinalitem.getzAttribute()+"', "+
                        "'" + zcdmTFinalitem.getzBreakFlg() + "', '" + zcdmTFinalitem.getzAdTime() + "', '" + zcdmTFinalitem.getzChanlCd() + "', " +
                        "'" + zcdmTFinalitem.getzChanlName() + "', " +
//					    	      		 "'"+zcdmTFinalitem.getzChanlType()+"', '"+zcdmTFinalitem.getzChanlRegion()+"', "+
                        "'" + zcdmTFinalitem.getzPlayDate() + "', " +
//					    	      		 "'"+zcdmTFinalitem.getzTeleplayBucd()+"', '"+zcdmTFinalitem.getzTeleplayBunm()+"', "+
//					    	      ""+zcdmTFinalitem.getzPlayCnt()+", '"+zcdmTFinalitem.getzExtend1()+"', '"+zcdmTFinalitem.getzExtend2()+"', "+
//					    	      "'"+zcdmTFinalitem.getzExtend3()+"', '"+zcdmTFinalitem.getzExtend4()+"', '"+zcdmTFinalitem.getzExtend5()+"', "+
                        "'" + covertStr(zcdmTFinalitem.getzCrusr()) + "', '" + getPlayDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) + "'," +
                        "'" + covertStr(zcdmTFinalitem.getzUpusr()) + "', '" + getPlayDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) + "',  " +
                        "'" + zcdmTFinalitem.getzSubjName() + "','" + zcdmTFinalitem.getzPgnam() + "','" + zcdmTFinalitem.getzAudioType() + "'," +
                        "'" + zcdmTFinalitem.getzPlayroomNm() + "','" + zcdmTFinalitem.getzMediaId() + "','" + zcdmTFinalitem.getzMediaName() + "'," +
                        "'" + zcdmTFinalitem.getzProInsert() + "');";
//					    	      		 "'"+zcdmTFinalitem.getzMakeSubjNm()+"','"+zcdmTFinalitem.getzProdType()+"');";
                try {
                    ll_finalitem = ll_finalitem + genericDao.updateBySqlStr(sql_item);
                } catch (Exception e) {
                    LOGGER.error("核心表存储播后单数据失败："+zcdmTFinalitem.toString()+"", e);
                    continue;
                }
            }

            //播后单信息下发8K运管平台
            JSONObject finalItemJson = new JSONObject();
            finalItemJson.put("cdmFinalDTOS", yyglFinalItems);
            try {
                InputStream inputStream = ContextHolder.class.getResourceAsStream("/config/yygl.properties");
                properties.load(inputStream);
                String finalItemYyglUrl = properties.getProperty("yygl.finalItemYyglUrl");
                String method = properties.getProperty("yygl.method");
                Integer tryNum = Integer.parseInt(properties.getProperty("yygl.tryNum"));
                HttpUtils.JsonHttpRequestPost(finalItemYyglUrl, method, finalItemJson, tryNum);
            } catch (IOException e) {
                LOGGER.error("播后单信息下发运管平台失败", e);
            }


//			ll_finalitem = genericDao.updateBySqlStr(sql_item);
        }


//		if(ll_finalitem >0) {
        int ll_inner = 0;
        int ll_sch = 0;
        int ll_finalseg = 0;
//			List<ZcdmTInnerad> zcdmTInneradList,List<ZcdmTAdSch> zcdmTAdSchList,List<ZcdmTFinalseg> finalSegList,List<ZcdmTDev> zcdmTDevList
        //节目分段
        if (finalSegList != null && !finalSegList.isEmpty()) {
            ZcdmTFinalseg zcdmTFinalseg = new ZcdmTFinalseg();
            String sql_finalseg = "";
            for (int i = 0; i < finalSegList.size(); i++) {
                zcdmTFinalseg = new ZcdmTFinalseg();
                zcdmTFinalseg = finalSegList.get(i);
                sql_finalseg = "";
                sql_finalseg = "insert into zcdm_t_finalseg (Z_SEG_ITEM_CD, Z_FATHER_ITEM_CD, Z_SEGMENT_NO," +
                        "      Z_SEGMENT_NM, Z_PLAY_TIME, Z_SEG_LENGTH," +
                        "      Z_SEG_STATUS)" +
                        "    values ('" + zcdmTFinalseg.getzSegItemCd() + "',  '" + zcdmTFinalseg.getzFatherItemCd() + "',  '" + zcdmTFinalseg.getzSegmentNo() + "',  " +
                        "      '" + zcdmTFinalseg.getzSegmentNm() + "',  '" + zcdmTFinalseg.getzPlayTime() + "',  '" + zcdmTFinalseg.getzSegLength() + "', " +
                        "      '" + zcdmTFinalseg.getzSegStatus() + "');";

                ll_finalseg = ll_finalseg + genericDao.updateBySqlStr(sql_finalseg);
            }


        }
        //			finalSegList
//			中插广告段
        if (zcdmTInneradList != null && !zcdmTInneradList.isEmpty()) {
            String sql_inner = "";
            ZcdmTInnerad zcdmTInnerad = new ZcdmTInnerad();
            for (int i = 0; i < zcdmTInneradList.size(); i++) {
                zcdmTInnerad = new ZcdmTInnerad();
                zcdmTInnerad = zcdmTInneradList.get(i);
                sql_inner = "";
                sql_inner = "insert into zcdm_t_innerad (Z_BRDCAST_INID, Z_PRO_ITEM_CD, Z_ITEMINDEX," +
                        "      Z_EVENT, Z_PLAY_TIME, Z_PRO_RTMLEN, " +
//							"      Z_AD_SEG_SEQ, Z_AD_SEGMARKIN, "
                        "Z_AD_SUBJ_CD, " +
                        "      Z_AD_SUBJ_NM, Z_PROCODE, Z_PGNAM, " +
                        "      Z_HD_FLAG, Z_AFD, Z_AUDIO_TYPE, " +
                        "      Z_CARRIER_TYPE, Z_AUD_VER, Z_AUD_NAME, " +
                        "      Z_CAP_VER, Z_CAP_NAME, Z_PLAY_FORM, " +
                        "      Z_IN_FORM, Z_INSERT_WAY, Z_AD_SEG_LENGTH," +
//							"      Z_MATE_DEST, Z_DATA_SOURCE, "
                        "Z_AD_SEGMENT_ID" +
                        "      )" +
                        "    values ('" + zcdmTInnerad.getzBrdcastInid() + "', '" + zcdmTInnerad.getzProItemCd() + "', " + zcdmTInnerad.getzItemindex() + "," +
                        "      '" + zcdmTInnerad.getzEvent() + "', '" + zcdmTInnerad.getzPlayTime() + "', '" + zcdmTInnerad.getzProRtmlen() + "', " +
//							"      '"+zcdmTInnerad.getzAdSegSeq()+"', '"+zcdmTInnerad.getzAdSegmarkin()+"', "
                        "'" + zcdmTInnerad.getzAdSubjCd() + "', " +
                        "      '" + zcdmTInnerad.getzAdSubjNm() + "', '" + zcdmTInnerad.getzProcode() + "', '" + zcdmTInnerad.getzPgnam() + "', " +
                        "      '" + zcdmTInnerad.getzHdFlag() + "', '" + zcdmTInnerad.getzAfd() + "', '" + zcdmTInnerad.getzAudioType() + "', " +
                        "      '" + zcdmTInnerad.getzCarrierType() + "', '" + zcdmTInnerad.getzAudVer() + "', '" + zcdmTInnerad.getzAudName() + "', " +
                        "      '" + zcdmTInnerad.getzCapVer() + "', '" + zcdmTInnerad.getzCapName() + "', '" + zcdmTInnerad.getzPlayForm() + "'," +
                        "      '" + zcdmTInnerad.getzInForm() + "', '" + zcdmTInnerad.getzInsertWay() + "', '" + zcdmTInnerad.getzAdSegLength() + "', " +
//							"      '"+zcdmTInnerad.getzMateDest()+"', '"+zcdmTInnerad.getzDataSource()+"', "
                        "'" + zcdmTInnerad.getzAdSegmentId() + "'" +
                        "      );";
                ll_inner = ll_inner + genericDao.updateBySqlStr(sql_inner);
            }


        }

        //广告素材
        if (zcdmTAdSchList != null && !zcdmTAdSchList.isEmpty()) {
            ZcdmTAdSch zcdmTAdSch = new ZcdmTAdSch();
            String sql_sch = "";

            for (int i = 0; i < zcdmTAdSchList.size(); i++) {
                zcdmTAdSch = new ZcdmTAdSch();
                sql_sch = "";
                zcdmTAdSch = zcdmTAdSchList.get(i);

                sql_sch = "insert into zcdm_t_ad_sch (Z_PRO_ITEM_CD, Z_AD_PROG_NO, " +
//							+ "Z_AD_SEGMENT_ID," +
                        "      Z_AD_ASSET_ID, Z_AD_MATERIALID, Z_AD_METERIAL_NM," +
                        "      Z_AD_MAT_LENGTH, Z_AD_BEG_TIME, Z_AD_SUBJ_CD," +
                        "      Z_AD_SUBJ_NM, Z_SUBJ_CD, Z_SUBJ_NAME," +
                        "      Z_HD_FLAG, Z_AFD, Z_AUDIO_TYPE," +
                        "      Z_AUD_VER, Z_AUD_NAME, Z_CAP_VER," +
                        "      Z_CAP_NAME, Z_AD_ITEMTYPE, Z_CRDAT)" +
//							"      Z_CRTIM, Z_UPDAT, Z_UPTIM," +
//							"      Z_DATA_SOURCE)" +
                        "    values ('" + zcdmTAdSch.getzProItemCd() + "', '" + zcdmTAdSch.getzAdProgNo() + "'," +
//									+ " '"+zcdmTAdSch.getzAdSegmentId()+"'," +
                        "      '" + zcdmTAdSch.getzAdAssetId() + "', '" + zcdmTAdSch.getzAdMaterialid() + "', '" + zcdmTAdSch.getzAdMeterialNm() + "'," +
                        "      '" + zcdmTAdSch.getzAdMatLength() + "', '" + zcdmTAdSch.getzAdBegTime() + "', '" + zcdmTAdSch.getzAdSubjCd() + "'," +
                        "      '" + zcdmTAdSch.getzAdSubjNm() + "', '" + zcdmTAdSch.getzSubjCd() + "', '" + zcdmTAdSch.getzSubjName() + "'," +
                        "      '" + zcdmTAdSch.getzHdFlag() + "', '" + zcdmTAdSch.getzAfd() + "', '" + zcdmTAdSch.getzAudioType() + "'," +
                        "      '" + zcdmTAdSch.getzAudVer() + "', '" + zcdmTAdSch.getzAudName() + "', '" + zcdmTAdSch.getzCapVer() + "'," +
                        "      '" + zcdmTAdSch.getzCapName() + "', '" + zcdmTAdSch.getzAdItemtype() + "', '" + this.getPlayDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) + "');";
//							"      '"+zcdmTAdSch.getzCrtim()+"', '"+zcdmTAdSch.getzUpdat()+"', '"+zcdmTAdSch.getzUptim()+"'," +
//							"      '"+zcdmTAdSch.getzDataSource()+"');";

                try {
                    ll_sch = ll_sch + genericDao.updateBySqlStr(sql_sch);
                } catch (Exception e) {
                    log.error("广告zcdm_t_ad_sch修改信息失败:", e);
                }
            }

        }

//
        log.debug("播后详情写入行数：" + ll_finalitem);
        log.debug("节目分段写入行数" + ll_finalseg);
        log.debug("广告分段写入行数" + ll_inner);
        log.debug("广告素材写入行数" + ll_sch);

        ll_return = 1;
//		}else {
//			ll_return = 0;
//		}
        return ll_return;

//		List<Map<String,?>> list = genericDao.executeSql(sql);

//		Condition condition = new Condition();
//
//		condition.add("zProRecCd", zcdmTProrec.getZProRecCd());
//		if (genericDao.updateByCondition(zcdmTProrec, null, condition) == 0) {
//			genericDao.insert(zcdmTProrec);
//			genericDao.batchInsert(list);
//			return 0; // 插入成功!
//		} else {
//			return 1; // 信息已存在!
//		}
    }

    private Map<String, Object> convertPoToMap(ZcdmTFinalitemWithBLOBs zcdmTFinalitem) {
        Map<String, Object> map = new HashMap<>();
        map.put("chanlCd", zcdmTFinalitem.getzChanlCd());
        map.put("subjCd", zcdmTFinalitem.getzSubjCd());
        map.put("subjName", zcdmTFinalitem.getzSubjName());
        map.put("procode", zcdmTFinalitem.getzProcode());
        map.put("pgnam", zcdmTFinalitem.getzPgnam());
        map.put("playTime", zcdmTFinalitem.getzPlayTime());
        map.put("playDate", zcdmTFinalitem.getzPlayDate());
        map.put("proRtmlen", zcdmTFinalitem.getzProRtmlen());
        map.put("isAd", zcdmTFinalitem.getzIsAd());
        map.put("adTime", zcdmTFinalitem.getzAdTime());
        return map;
    }


    public String getPlayDate(Date date, SimpleDateFormat format) {

//	        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String sdate = format.format(date);

        return sdate;

    }

    public String covertStr(String str) {

//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str_new = "";
        if (str != null) {
            str_new = str;
        } else {
            str_new = "";
        }

        return str_new;

    }

    public int covertInt(String str) {

//      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        int str_new = 0;
        if (str == null || str.equals("")) {
            str_new = 0;
        } else {
            str_new = Integer.valueOf(str);
        }

        return str_new;

    }


}
